home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig10_02.jar
/
Ch10
/
Fig10_02
/
Cylindr1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-28
|
693b
|
29 lines
// Fig. 10.2: cylindr1.cpp
// Member and friend function definitions for class Cylinder
#include "cylindr1.h"
Cylinder::Cylinder( double h, double r, int x, int y )
: Circle( r, x, y ) // call base-class constructor
{ setHeight( h ); }
void Cylinder::setHeight( double h )
{ height = h > 0 ? h : 0; }
double Cylinder::getHeight() { return height; }
double Cylinder::area() const
{
// surface area of Cylinder
return 2 * Circle::area() +
2 * 3.14159 * getRadius() * height;
}
double Cylinder::volume() const
{ return Circle::area() * height; }
void Cylinder::print() const
{
Circle::print();
cout << "; Height = " << height;
}